#include<iostream>
#include<memory>

class AbstractProductA
{
public:
    //该抽象产品负责生产具体产品AA和具体产品AB
    virtual ~AbstractProductA(){};
    virtual void ProductInfo()const{};
};

class AbstractProductB
{
public:
    //该抽象产品负责生产具体产品BA和具体产品BB
    virtual ~AbstractProductB(){};
    virtual void ProductInfo()const{};
};


class ConcreteProductAA: public AbstractProductA
{
public:
    //具体产品AA
     void ProductInfo()const override{std::cout << "ProductAA" << std::endl;};
};

class ConcreteProductAB: public AbstractProductA
{
public:
    //具体产品AB
     void ProductInfo()const override{std::cout << "产品AB" << std::endl;};
};
class ConcreteProductBA: public AbstractProductB
{
public:
    //具体产品AA
     void ProductInfo()const override{std::cout << "ProductBA" << std::endl;};
};
class ConcreteProductBB: public AbstractProductB
{
public:
    //具体产品BB
     void ProductInfo()const override{std::cout << "产品BB" << std::endl;};
};

class AbstractFactory
{
public:
    //该抽象工厂负责生产产品A和产品B
    virtual ~AbstractFactory(){};
    virtual std::shared_ptr<AbstractProductA> produceProductA()const{};
    virtual std::shared_ptr<AbstractProductB> produceProductB()const{};
};

class ConcreteFactoryA:public AbstractFactory
{
public:
    //该具体工厂负责生产产品AA 和产品BA
    std::shared_ptr<AbstractProductA> produceProductA()const override{return std::make_shared<ConcreteProductAA>();};
    std::shared_ptr<AbstractProductB> produceProductB()const override{return std::make_shared<ConcreteProductBA>();};
};

class ConcreteFactoryB:public AbstractFactory
{
public:
    //该具体工厂负责生产产品AB 和产品BB
    std::shared_ptr<AbstractProductA> produceProductA()const override{return std::make_shared<ConcreteProductAB>();};
    std::shared_ptr<AbstractProductB> produceProductB()const override{return std::make_shared<ConcreteProductBB>();};
};


int main(int argc, char const *argv[])
{
    AbstractFactory *factory;
    std::shared_ptr<AbstractProductB> product;
    factory = new ConcreteFactoryA;
    product = factory->produceProductB();
    product->ProductInfo();
    return 0;
}
